package me.zhengjie.pm.projectplan.domain;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.pm.projectbase.domain.ProjectBase;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @author ZGZ
* @date 2020-04-25
*/
@Entity
@Data
@Table(name="project_plan")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public class ProjectPlan implements Serializable {

    /** ID */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    /** 项目 */
    @Column(name = "project_id")
    private Integer projectId;
    @OneToOne
    @JoinColumn(name = "project_id", insertable = false, updatable = false)
    private ProjectBase projectBase;

    /** 重要程度 */
    @Column(name = "importance")
    private String importance;

    /** 主要完成形式/成果 */
    @Column(name = "achievement")
    private String achievement;

    /** 计划开始时间 */
    @Column(name = "plan_start_time")
    private Timestamp planStartTime;

    /** 计划完成时间 */
    @Column(name = "plan_finish_time")
    private Timestamp planFinishTime;

    /** 实际开始时间 */
    @Column(name = "start_time")
    private Timestamp startTime;

    /** 实际完成时间 */
    @Column(name = "finish_time")
    private Timestamp finishTime;

    /** 部门项目工作文档位置 */
    @Column(name = "doc_path")
    private String docPath;

    /** 计划依据 */
    @Column(name = "plan_basis")
    private String planBasis;

    /** 项目密级 */
    @Column(name = "secret_level")
    private String secretLevel;

    /** 研制内容 */
    @Column(name = "contents")
    private String contents;

    /** 部门项目管理文档位置 */
    @Column(name = "mng_doc_path")
    private String mngDocPath;

    public void copy(ProjectPlan source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}